Imports Auditing.Entities
Imports DataAccess.Base
Imports DataAccess

Public Class LogDAO
    Inherits TableDAO(Of Log)

    Public Sub New()
        Me.TableName = "Auditing_Logs"
        Me.IDColumn = "LogId"
    End Sub

    Public Sub Clear(ByVal fromDate As String, ByVal toDate As String)
        Dim sql As String
        Dim dFrom As Date
        Dim dTo As Date

        If Date.TryParse(fromDate, dFrom) And Date.TryParse(toDate, dTo) Then
            sql = "DELETE FROM {0} WHERE Date BETWEEN '{1:yyyy/MM/dd}' AND '{2:yyyy/MM/dd}'"
            sql = String.Format(sql, Me.TableName, dFrom, dTo)
        Else
            sql = "DELETE FROM {0}"
        End If

        DataHelper.Current.ExecuteNonQuery(sql)
    End Sub
End Class
